package com.djinfo.work.controller;

import com.djinfo.work.common.bean.AjaxJson;
import com.djinfo.work.entity.*;
import com.djinfo.work.service.*;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;

import javax.servlet.http.HttpSession;

/**
 * 公告
 */
@Controller
@RequestMapping("/notice")
public class NoticeController {
	private static final Log log = LogFactory.getLog(NoticeController.class);
	/**
	 * 自动注入
	 */
	@Autowired
	private NoticeService noticeService;


	/**
	 * 公告列表
	 */
	@RequestMapping("/list.do")
	@ResponseBody
	public AjaxJson list(SysNoticeEntity sysNoticeEntity, Integer pagenum, Integer pagesize){
		AjaxJson ajaxJson = noticeService.list(sysNoticeEntity, pagenum, pagesize);
		return ajaxJson;
	}



	/**
	 * 获取公告对象信息
	 */
	@RequestMapping("/redirect.do")
	public ModelAndView redirect(SysNoticeEntity sysNoticeEntity){
		ModelAndView modelAndView = noticeService.redirect(sysNoticeEntity);
		return modelAndView;
	}

	/**
	 * 保存
	 */
	@RequestMapping("/saveOrUpdate.do")
	@ResponseBody
	public AjaxJson save(SysNoticeEntity sysNoticeEntity, HttpSession session){
		AjaxJson ajaxJson = noticeService.save(sysNoticeEntity,session);
		return ajaxJson;
	}



	/**
	 * 修改
	 */
	@RequestMapping("/update.do")
	@ResponseBody
	public AjaxJson update(SysNoticeEntity sysNoticeEntity, HttpSession session){
		AjaxJson ajaxJson = noticeService.update(sysNoticeEntity,session);
		return ajaxJson;
	}

	/**
	 * 删除
	 */
	@RequestMapping("/delete.do")
	@ResponseBody
	public AjaxJson delete(SysNoticeEntity sysNoticeEntity){
		AjaxJson ajaxJson = noticeService.deletes(sysNoticeEntity);
		return ajaxJson;
	}

	/**
	 * 批量删除
	 */
	@RequestMapping("/deleteSome.do")
	@ResponseBody
	public AjaxJson deleteSome(String ids){
		AjaxJson ajaxJson = noticeService.deleteSome(ids);
		return ajaxJson;
	}

	/**
	 *初始化数据
	 */
	@RequestMapping("/getInitInfo.do")
	@ResponseBody
	public AjaxJson getInitInfo(HttpSession session){
		AjaxJson ajaxJson = noticeService.getInitInfo(session);
		return ajaxJson;
	}

	/**
	 *更新状态
	 */
	@RequestMapping("/updateStatus.do")
	@ResponseBody
	public AjaxJson updateStatus(String id,HttpSession session){
		AjaxJson ajaxJson = noticeService.updatestatus(id,session);
		return ajaxJson;
	}

}
